<?php
require_once  '../classes/ConnectionDB.php';
require_once  '../classes/UtenteManager.php';
$db =ConnectionDB::getInstance()->connectToDB();

$fromDay = $_POST['fromDay'];
$fromMonth = $_POST['fromMonth'];
$fromYear= $_POST['fromYear'];
$fromHour = $_POST['fromHour'];
$fromMinute = $_POST['fromMinute'];

$toDay = $_POST['toDay'];
$toMonth = $_POST['toMonth'];
$toYear= $_POST['toYear'];
$toHour = $_POST['toHour'];
$toMinute = $_POST['toMinute'];

$from = mktime((int)$fromHour, (int)$fromMinute, 0,  (int)$fromMonth, (int)$fromDay, (int)$fromYear);
$to = mktime((int)$toHour, (int)$toMinute, 0,  (int)$toMonth, (int)$toDay,  (int)$toYear);

$result = UtenteManager::getInstance()->getUtentiByData($db, $from, $to);
$result->bind_result($codice,$username, $nome, $cognome);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form method="POST" action="reportUtentiNav.php">
            <label>From : </label>
            <input type="hidden" name="fromHour" value="0" />
            <input type="hidden" name="fromMinute" value="0" />
            <input type="hidden" name="toHour" value="23" />
            <input type="hidden" name="toMinute" value="59" />

            <input type="text" name="fromDay" size="2" value="<?php echo $fromDay?>"/>
            <input type="text" name="fromMonth" size="2" value="<?php echo $fromMonth?>" />
            <input type="text" name="fromYear" size="4" value="<?php echo $fromYear?>" /><br>
            <label>To : </label>
            <input type="text" name="toDay" size="2" value="<?php echo $toDay?>"/>
            <input type="text" name="toMonth" size="2" value="<?php echo $toMonth?>"/>
            <input type="text" name="toYear" size="4"  value="<?php echo $toYear?>"/><br>
            <input type="submit" value="Cerca" />
        </form>
        <table>
            <tr>
                <th>Codice</th>
                <th>Username</th>
                <th>Nome</th>
                <th>Cognome</th>
                <th>Associa</th>
            </tr>

            <?php
            $result->bind_result($codice,$username, $nome, $cognome);
            while($result->fetch())
            {
                echo '<tr>';
                echo '  <td>'. $codice. '</td>';
                echo '  <td>'. $username.'</td>';
                echo '  <td>'. $nome.'</td>';
                echo '  <td>'. $cognome.'</td>';
                echo '<td><a href=\'associaUtenteClasse.php?codice='.$codice.'\'>Associa a classe</a></td>';
                echo '</tr>';
            }
            ?>
        </table>
    </body>
</html>
